package com.mls.fivedistrict.server.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.mls.fivedistrict.dao.MenuMapper;
import com.mls.fivedistrict.pojo.Menu;
import com.mls.fivedistrict.server.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Five Team
 * @since 2018-06-14
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
    @Autowired
    MenuMapper menuMapper;
    @Override
    public List<Menu> selectList(Wrapper<Menu> wrapper) {
        List<Menu> menuList = menuMapper.selectList(wrapper);
        for (Menu menu: menuList) {
            if(menu.getParentId()==0){
                menu.setChildren(menuMapper.selectChildren(menu.getId()));
            }
        }
        return menuList;
    }
}
